<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title>退货明细</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>

<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input">
                    <div class="textalign1">通用名：</div>
                    <div class="boxinput">
                         <input type="text" class="textinput" id="drugName" name="drugName"  placeholder="通用名/<spring:message code="message.listForm.pinYinMa"/>" />
                    </div>
                    <div class="textalign1">生产企业：</div>
                    <div class="boxinput">
                         <input type="text" class="textinput" id="compName" name="compName"  placeholder="生产企业/<spring:message code="message.listForm.pinYinMa"/>" />
                    </div>
                    <div class="textalign1">批号：</div>
                    <div class="boxinput"> 
                       <input type="text" class="textinput" id="approveCode" name="approveCode"  placeholder="批号" />
                    </div> 
					<div class="textalign1" >
                        <button id="selectDicCompType" type="button" class="btn btn-success btn-sm" onclick="search()">
                            <spring:message code="message.button.seachSpacing"/>
                        </button>
                    </div>
                </div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">   
        $(function () {
        	
            //绑定回车
            $('#drugName,#drugCode,#compName,#approveCode').bind('keydown', function(event) {
                if (event.keyCode == "13") {
                    $('#selectDicCompType').click();
                }
            }); 
            $("#drugName").focus();//加载页面光标在第一个查询框内
            
            
            $("#gridlist").jqGrid({
                url: "getReturnDetail.html",
                mtype: "POST",
                datatype: "json",
                postData:{"retCode" : "${retCode}"},
                autowidth: true,
                shrinkToFit: false,
                height: 350,
                colNames: [
                    '退货数量',
                    
                    '退货原因',
                    
                    '通用名',
                    '剂型',
                    '规格',
                    '单位',
                    '转换系数',
                    '生产企业',
                    '国药准字',
                    '批次号',
                    '到货数量',
                    '有效期',
                    '采购价'
                  
                ],
                colModel: [
                   { name: 'retCount', width: 80, align: "right" ,sortable:false },
                  
                   { name: 'retReason', width: 180, align: "center" ,sortable:false },
                  
                   { name: 'drugName', width: 180, align: "left", sortable:false },
                   { name: 'formName', width: 80, align: "center", sortable:false },
                   { name: 'specName', width: 80, align: "center", sortable:false },
                   { name: 'unitName', width: 80, align: "center", sortable:false },
                   { name: 'factor', width: 80, align: "center", sortable:false },
                   { name: 'prodCompName', width: 200, align: "left", sortable:false },
                   { name: 'drugMedicine', width: 80, align: "center", sortable:false },
                   { name: 'approveCode', width: 100, align:"center", sortable:false },
                   { name: 'totalAmount', width: 80, align: "right", sortable:false },
                   { name: 'credential', width: 100, align:"center", sortable:false },
                   { name: 'proPrice', width: 80, align: "right", sortable:false,
                       formatter:function(val, opts, row){
                           return formatAmount(val);
                       }
                   }
                 
                ],
                rowNum: 20,
                rowList: [10, 20,50,100],
                rownumbers: true,
                multiselect: false,
                pager: "#gridpage",
                viewrecords: true,
                gridComplete: function(){
                      //序号列宽度自适应（参数为jqgridID）
                      autoRNWidth("gridlist");
                },
                caption: "退货明细列表",
                jsonReader: {
                    repeatitems: false,
                    id: "retDetailId"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
        
        /* 查询 */
        function search(page) {
            var drugName = $.trim($("#drugName").val());
            var drugCode = $.trim($("#drugCode").val());
            var compName = $.trim($("#compName").val());
            var approveCode = $.trim($("#approveCode").val());
            $("#gridlist").jqGrid("clearGridData");
                $("#gridlist").jqGrid('setGridParam',{  
                mtype: "POST",
                datatype:'json',
                postData:{
                    "drugName":drugName, 
                    "drugCode":drugCode,
                    "compName":compName,
                    "approveCode":approveCode
                },
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
    </script>
</body>
</html>